using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Deepcode.Flux.Core.Data;

namespace Deepcode.Flux.Core.Systems.Addins
{
	/// <summary>
	/// Represents a known addin record in the Flux database (NOT in the AddinTree...)
	/// </summary>
	public class KnownAddin
	{
		// Private fields for storing record fields //
		private int _PK_ID = -1;
		private string _dbGUID = "";
		private string _AddinName = "";
		private string _VersionString = "";

		// Public fields exposing record fields //
		public int PK_ID { get { return _PK_ID; } set { _PK_ID = value; } }
		public Guid GUID { get { return new Guid(_dbGUID); } set { _dbGUID = value.ToString(); } }
		public string dbGUID { get { return _dbGUID; } }
		public string AddinName { get { return _AddinName; } set { _AddinName = value; } }
		public string VersionString { get { return _VersionString; } set { _VersionString = value; } }

		// Constructor to create new without loading
		public KnownAddin() { }

		// Constructor loading from a data row
		public KnownAddin(DataRow InitFromRow)
		{
			_PK_ID = SQLUtility.DBNull(InitFromRow["PK_ID"], -1);
			_dbGUID = SQLUtility.DBNull(InitFromRow["GUID"], "");
			_AddinName = SQLUtility.DBNull(InitFromRow["AddinName"], "");
			_VersionString = SQLUtility.DBNull(InitFromRow["VersionString"], "");
		}
	}
}
